﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using System.Web.Routing;
using System.Web.Security;
using TruongVuWebsite;

namespace TruongVuWebsite
{
    public class Global : HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
            //AuthConfig.RegisterOpenAuth();

            Application["ActiveUsers"] = 0;
        }

        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown

        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

        }

        void Session_Start(object sender, EventArgs e)
        {
            Application["ActiveUsers"] = (int)Application["ActiveUsers"] + 1;

            // increase
            TruongVu.Business.CounterModel counterModel = new TruongVu.Business.CounterModel();
            counterModel.IncreaseCounterBy1();
        }

        void Session_End(object sender, EventArgs e)
        {
            Application["ActiveUsers"] = (int)Application["ActiveUsers"] - 1;
        }
    }
}
